package com.bt7274.enums;


public enum SortType {
    RELEVANCE("relevance"),
    HOT("hot"),
    TIME("time");

    private final String value;

    SortType(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    /**
     * 根据传入的值获取对应的枚举实例
     * @param value 传入的排序值
     * @return 对应的枚举实例，如果未匹配则返回 RELEVANCE
     */
    public static SortType fromValue(String value) {
        for (SortType sortType : SortType.values()) {
            if (sortType.value.equalsIgnoreCase(value)) {
                return sortType;
            }
        }
        return RELEVANCE;
    }
}